<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2>请假记录</h2>
    </div>
    <div class="clearfix">
        <div class="col-xs-10">
            <a class="btn btn-success" href="{:U('addrecord')}">新增</a>
            <button class="btn ajax-post btn-primary" url="{:U('setStatus',array('method'=>'resume','model'=>'core_leave'))}"
                    target-form="ids">通过
            </button>
            <button class="btn ajax-post btn-warning" url="{:U('setStatus',array('method'=>'forbid','model'=>'core_leave'))}"
                    target-form="ids">不通过
            </button>
            <button class="btn ajax-post btn-danger" url="{:U('setStatus',array('method'=>'delete','model'=>'core_leave'))}"
                    target-form="ids">删除
            </button>
            <br/>
            <br/>
            <script src="__PUBLIC__//date/js/jquery.1.7.2.min.js"></script>
            <script src="__PUBLIC__//date/js/mobiscroll_002.js" type="text/javascript"></script>
            <script src="__PUBLIC__//date/js/mobiscroll_004.js" type="text/javascript"></script>
            <link href="__PUBLIC__//date/css/mobiscroll_002.css" rel="stylesheet" type="text/css">
            <link href="__PUBLIC__//date/css/mobiscroll.css" rel="stylesheet" type="text/css">
            <script src="__PUBLIC__//date/js/mobiscroll.js" type="text/javascript"></script>
            <script src="__PUBLIC__//date/js/mobiscroll_003.js" type="text/javascript"></script>
            <script src="__PUBLIC__//date/js/mobiscroll_005.js" type="text/javascript"></script>
            <link href="__PUBLIC__//date/css/mobiscroll_003.css" rel="stylesheet" type="text/css">
            <php>
                    $lastmonth = date('Y-m-d H:i:s',strtotime('-1 month'));
                    $date = date('Y-m-d H:i:s');
                </php>
                    <form action="{:U('index')}" method="post">
                    <label class="item-label">请假日期</label><br/>
                    <input value="{$lastmonth}" class="" readonly="readonly" name="createtime" id="staDate" type="text">
                    <input value="{$date}" class="" readonly="readonly" name="endDate" id="endDate" type="text">
                <script type="text/javascript">
                    $(function () {
                        var currYear = (new Date()).getFullYear();  
                        var opt={};
                        opt.date = {preset : 'date'};
                        opt.datetime = {preset : 'datetime'};
                        opt.time = {preset : 'time'};
                        opt.default = {
                            theme: 'android-ics light', //皮肤样式
                            display: 'modal', //显示方式 
                            mode: 'scroller', //日期选择模式
                            dateFormat: 'yyyy-mm-dd',
                            lang: 'zh',
                            showNow: true,
                            nowText: "今天",
                            startYear: currYear - 10, //开始年份
                            endYear: currYear + 10 //结束年份
                        };

                        $("#staDate").mobiscroll($.extend(opt['date'], opt['default']));
                        var optDateTime = $.extend(opt['datetime'], opt['default']);
                        var optTime = $.extend(opt['time'], opt['default']);
                        $("#staDate").mobiscroll(optDateTime).datetime(optDateTime);
                        $("#appTime").mobiscroll(optTime).time(optTime);

                        $("#endDate").mobiscroll($.extend(opt['date'], opt['default']));
                        var optDateTime = $.extend(opt['datetime'], opt['default']);
                        var optTime = $.extend(opt['time'], opt['default']);
                        $("#endDate").mobiscroll(optDateTime).datetime(optDateTime);
                        $("#appTime").mobiscroll(optTime).time(optTime);
                    });
                </script> 
        <br/>
        <br/>
            <div class="input-group" style="display: inline-block;">
                <input type="text" name="keyword" class="search-input form-control" value="" placeholder="请输入请假原因" style="width: 80%;">
        <br/>
        <br/>
                <input type="submit" name="anniu" value="搜索">
            </div>
            </form>
        </div>
    </div>
 
    <div class="data-table with-padding">
        <table class="table table-bordered table-striped ">
            <thead>
            <tr>
                <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
                <th class="">id</th>
                <th class="">请假类型</th>
                <th class="">请假日期</th>
                <th class="">请假天数</th>
                <th class="">请假原因</th>
                <th class="">创建时间</th>
                <th class="">更新时间</th>
                <th class="">审核时间</th>
                <th class="">状态</th>
                <th class="">操作</th>
            </tr>
            </thead>
            <tbody>
            <notempty name="_list">
                <volist name="_list" id="vo">
                    <tr>
                        <td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}"/></td>
                        <td>{$vo.id}</td>
                        <td>{$vo.lname}</td>
                        <td>{$vo.leave_date|time_format}</td>
                        <td>{$vo.days}</td>
                        <td>{$vo.reason}</td>
                        <td>
                        <if condition="$vo[create_time] neq 0 ">
                            {$vo.create_time|time_format}
                        <else/>
                            暂无
                        </if>
                        </td>
                        <td>
                        <if condition="$vo[update_time] neq 0 ">
                            {$vo.update_time|time_format}
                        <else/>
                            暂无
                        </if>
                        </td>
                        <td>
                        <if condition="$vo[check_time] neq 0 ">
                            {$vo.check_time|time_format}
                        <else/>
                            暂无
                        </if>
                        </td>
                        <td>
                            <if condition="$vo.status eq 1">
                            <span style="color:green;">通过</span>
                            </if>
                            <if condition="$vo.status eq 2">
                            <span style="color:red;">不通过</span>
                            </if>
                            <if condition="$vo.status eq 0">
                            <span style="color:red;">审核中</span>
                            </if>
                        </td>
                        <td>
                            <a class="status status_1" href="{:U('editimpl',array('id'=>$vo[id]))}">编辑</a>
                            <if condition="$vo.status neq 1">
                            <a class="status status_2 ajax-get" onclick="javascript:if(confirm('确定通过吗?')){return true} else{return false;}"href="{:U('setStatus',array('method'=>'resume',id=>$vo[id],'model'=>'core_leave'))}">通过</a>
                            </if>
                            <if condition="$vo.status neq 2">
                            <a class="status status_4 ajax-get" href="{:U('setStatus',array('method'=>'forbid',id=>$vo[id],'model'=>'core_leave'))}">不通过</a>
                            </if>
                            <a class="status status_4 ajax-get" href="{:U('setStatus',array('method'=>'delete',id=>$vo[id],'model'=>'core_leave'))}">删除</a>
                            
                        </td>
                    </tr>
                </volist>
                <else/>
                <td colspan="10" class="text-center">{:L('_ADMIN_USER_EMPTY_')}</td>
            </notempty>
            </tbody>
        </table>
    </div>
    <div class="with-padding">
        {$_page}
    </div>
</block>

<block name="script">
    <script src="__CSS__/status.css"></script>
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>
    
    <script type="text/javascript">
        //搜索功能
        $("#search").click(function () {
            var url = $(this).attr('url');
            var query = $('.search-form').find('input').serialize();
            query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g, '');
            query = query.replace(/^&/g, '');
            if (url.indexOf('?') > 0) {
                url += '&' + query;
            } else {
                url += '?' + query;
            }
            window.location.href = url;
        });
        //回车搜索
        $(".search-input").keyup(function (e) {
            if (e.keyCode === 13) {
                $("#search").click();
                return false;
            }
        });
        //导航高亮
        highlight_subnav("{:U('index')}");
    </script>
</block>